package com.nbsaas.boot.wms.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "库存事务", model = "库存事务")
@Entity
@Table(name = "bs_inventory_transaction")
@Comment("库存事务表")
public class InventoryTransaction extends AbstractEntity {

    @Comment("事务编号")
    @SearchItem(name = "transactionNo", key = "transactionNo", label = "事务编号")
    @FormField(title = "事务编号", sortNum = "1", grid = true, required = true)
    @Column(length = 100, nullable = false, unique = true)
    private String transactionNo;

    @Comment("商品ID")
    @FormField(title = "商品ID", sortNum = "2", grid = true, required = true)
    private Long productId;

    @Comment("SKU ID")
    @FormField(title = "SKU ID", sortNum = "3", grid = true, required = true)
    private Long skuId;

    @Comment("仓库ID")
    @FormField(title = "仓库ID", sortNum = "4", grid = true, required = true)
    private Long warehouseId;

    @Comment("货位ID")
    @FormField(title = "货位ID", sortNum = "5", grid = true)
    private Long locationId;

    @Comment("事务类型")
    @FormField(title = "事务类型", sortNum = "6", grid = true, type = InputType.select)
    @Column(length = 20)
    private String type; // IN-入库, OUT-出库, TRANSFER-调拨, ADJUST-调整

    @Comment("事务子类型")
    @FormField(title = "事务子类型", sortNum = "7", grid = true, type = InputType.select)
    @Column(length = 20)
    private String subType; // PURCHASE-采购入库, SALE-销售出库, RETURN-退货, TRANSFER_IN-调拨入库, TRANSFER_OUT-调拨出库

    @Comment("变动数量")
    @FormField(title = "变动数量", sortNum = "8", grid = true, type = InputType.el_input_number, sort = true)
    private Integer quantity;

    @Comment("变动前数量")
    @FormField(title = "变动前数量", sortNum = "9", grid = true, type = InputType.el_input_number)
    private Integer beforeQuantity;

    @Comment("变动后数量")
    @FormField(title = "变动后数量", sortNum = "10", grid = true, type = InputType.el_input_number)
    private Integer afterQuantity;

    @Comment("单位成本")
    @FormField(title = "单位成本", sortNum = "11", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal unitCost;

    @Comment("总成本")
    @FormField(title = "总成本", sortNum = "12", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal totalCost;

    @Comment("关联单据号")
    @FormField(title = "关联单据号", sortNum = "13", grid = true)
    @Column(length = 100)
    private String relatedOrderNo;

    @Comment("关联单据类型")
    @FormField(title = "关联单据类型", sortNum = "14", grid = true, type = InputType.select)
    @Column(length = 20)
    private String relatedOrderType; // PURCHASE_ORDER-采购单, SALE_ORDER-销售单, TRANSFER_ORDER-调拨单

    @Comment("批次号")
    @FormField(title = "批次号", sortNum = "15", grid = true)
    @Column(length = 100)
    private String batchNo;

    @Comment("事务状态")
    @FormField(title = "事务状态", sortNum = "16", grid = true, type = InputType.select)
    @Column(length = 20)
    private String status; // PENDING-待处理, PROCESSING-处理中, COMPLETED-已完成, CANCELLED-已取消

    @Comment("备注")
    @FormField(title = "备注", sortNum = "17", type = InputType.richText, col = 23)
    @Column(length = 1000)
    private String note;
} 